#ifndef frm_control_TMover_H
#define frm_control_TMover_H

#include "frm_control_TPanel.h"

namespace frm { namespace control {

///////////////////////////////////////////////////////////////////////////////

struct TMover : public TPanel
{
  struct TState : public svl::TSet
  {
    enum EState { Left = 0,Top = 1,Right = 2,Bottom = 3 };
    //
    svlTSet(TState,EState);
  };
  struct TStyle : public TPanel::TStyle
  {
    TStyle();
    virtual TState GetState() =0;
  };
  struct TStyleL : public TStyle { TStyleL(); virtual TState GetState() { return TState() << TState::Left;} };
  struct TStyleT : public TStyle { TStyleT(); virtual TState GetState() { return TState() << TState::Top;} };
  struct TStyleR : public TStyle { TStyleR(); virtual TState GetState() { return TState() << TState::Right;} };
  struct TStyleB : public TStyle { TStyleB(); virtual TState GetState() { return TState() << TState::Bottom;} };
  //
  struct TStyleLTRB : public TStyle { TStyleLTRB(); virtual TState GetState() { return TState() << TState::Left << TState::Top << TState::Right << TState::Bottom;} };
  //
  struct TStyleLT : public TStyle { TStyleLT(); virtual TState GetState() { return TState() << TState::Left << TState::Top;} };
  struct TStyleRT : public TStyle { TStyleRT(); virtual TState GetState() { return TState() << TState::Right << TState::Top;} };
  struct TStyleLB : public TStyle { TStyleLB(); virtual TState GetState() { return TState() << TState::Left << TState::Bottom;} };
  struct TStyleRB : public TStyle { TStyleRB(); virtual TState GetState() { return TState() << TState::Right << TState::Bottom;} };

  //////////////
  struct TStyles
  {
    TStyleL L; TStyleT T; TStyleR R; TStyleB B;
    TStyleLTRB LTRB;
    TStyleLT LT; TStyleRT RT; TStyleLB LB; TStyleRB RB;
    //
    TStyles();
    //
    TStyle &Get(TState V) { return *s[V.GetBits()];}
    
  private:
    TStyle *s[16];
  };
  //
  TMover(TWindow &Window,TState State);
  //
  TMover &SetStyle(TStyle &V);
  //
  virtual void TComponent_Mouse(TMouse Mouse);

private:
  TState state;
  grf::TPoint ptBegin;
  grf::TRect rectBegin;
  TStyle *style;
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////

struct TMoverRB : public TMover
{
  struct TStyle : public TStyleRB {};
  //
  TMoverRB(TWindow &Window) : TMover(Window,TState() << TState::Right << TState::Bottom) {}
  //
  TMoverRB &SetStyle(TStyle &V) { TMover::SetStyle(V); return *this;} 
};

///////////////////////////////////////////////////////////////////////////////

}}

#endif
